package com.xy.cloud.kafka;

import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

import java.util.Optional;

@Component
@Slf4j
public class AuthKafkaConsumer {


  /*  @KafkaListener(topicPartitions =
            {@TopicPartition(topic = "test-topic",
                    partitions = {"1", "2"})
            }
    )*/

    @KafkaListener(topics = {"test-topic"})
    public void consumer(ConsumerRecord consumerRecord) {
        Optional<Object> kafkaMassage = Optional.ofNullable(consumerRecord.value());
        if (kafkaMassage.isPresent()) {
            Object o = kafkaMassage.get();
            System.out.println("Auth ---- 接收到的消息是：" + o);
        }
    }



}
